﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonsterEngine.Interfaces;
using MonsterEngine.Adapters;
using MonsterEngine.Entities;

namespace MonsterEngine.Managers
{
    /// <summary>
    /// This manager might have to go away, I am throwing too much into this
    /// and should probably break it out into an "AccountManager" class etc
    /// </summary>
    public class DBManager
    {
        public bool SaveBattleResults(List<IFightable> players)
        {
            players.ForEach(player =>
                {
                    MongoAdapter<IFightable> mAdp = new MongoAdapter<IFightable>();
                    IFightable fighter = mAdp.GetSingleObject(player.CharId.ToString());
                    if (fighter == null)
                    {
                        mAdp.InsertObject(player);
                    }
                    else
                    {
                        mAdp.UpdateSingleObject(player);
                    }
                });
            return true;
        }
    }
}
